package com.zmq.pic.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;

/**
 * 菜单 entity.
 * 
 * @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "pic_menu")
public class PicMenu extends com.zmq.pic.entity.BaseEntity implements
		java.io.Serializable {

	private static final long serialVersionUID = -2048651098140164502L;
	// Fields

	private Long id;
	/**
	 * 菜单名称
	 */
	private String menuName;
	/**
	 * 菜单路径
	 */
	private String url;
	/**
	 * 排序
	 */
	private Integer sort;
	/**
	 * 父菜单
	 */
	private PicMenu picMenu;
	private Set<PicMenu> picMenus = new HashSet<PicMenu>(0);
	private Set<PicRoleMenu> picRoleMenus = new HashSet<PicRoleMenu>(0);

	// Constructors

	/** default constructor */
	public PicMenu() {
	}

	/** minimal constructor */
	public PicMenu(String menuName, String url) {
		this.menuName = menuName;
		this.url = url;
	}

	/** full constructor */
	public PicMenu(PicMenu picMenu, String menuName, String url, Integer sort,
			Set<PicMenu> picMenus, Set<PicRoleMenu> picRoleMenus) {
		this.picMenu = picMenu;
		this.menuName = menuName;
		this.url = url;
		this.sort = sort;
		this.picMenus = picMenus;
		this.picRoleMenus = picRoleMenus;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "ID", nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PARENT_ID", unique = true)
	public PicMenu getPicMenu() {
		return this.picMenu;
	}

	public void setPicMenu(PicMenu picMenu) {
		this.picMenu = picMenu;
	}

	@Column(name = "MENU_NAME", nullable = false, length = 64)
	public String getMenuName() {
		return this.menuName;
	}

	public void setMenuName(String menuName) {
		this.menuName = menuName;
	}

	@Column(name = "URL", nullable = false, length = 128)
	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@Column(name = "SORT")
	public Integer getSort() {
		return this.sort;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "picMenu")
	public Set<PicMenu> getPicMenus() {
		return this.picMenus;
	}

	public void setPicMenus(Set<PicMenu> picMenus) {
		this.picMenus = picMenus;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "picMenu")
	public Set<PicRoleMenu> getPicRoleMenus() {
		return this.picRoleMenus;
	}

	public void setPicRoleMenus(Set<PicRoleMenu> picRoleMenus) {
		this.picRoleMenus = picRoleMenus;
	}

	@Override
	public String toString() {
		return "PicMenu [id=" + id + ", menuName=" + menuName + ", picMenu="
				+ picMenu + ", picMenus=" + picMenus + ", picRoleMenus="
				+ picRoleMenus + ", sort=" + sort + ", url=" + url + "]";
	}

}